-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
splits out gossip CrdsData out of crds_value.rs #3463
Conversation
ca2f999
to
4d4be4d
Compare
pub(crate) fn wallclock(&self) -> u64 { | ||
match self { | ||
CrdsData::LegacyContactInfo(contact_info) => contact_info.wallclock(), | ||
CrdsData::Vote(_, vote) => vote.wallclock, | ||
CrdsData::LowestSlot(_, obj) => obj.wallclock, | ||
CrdsData::LegacySnapshotHashes(hash) => hash.wallclock, | ||
CrdsData::AccountsHashes(hash) => hash.wallclock, | ||
CrdsData::EpochSlots(_, p) => p.wallclock, | ||
CrdsData::LegacyVersion(version) => version.wallclock, | ||
CrdsData::Version(version) => version.wallclock, | ||
CrdsData::NodeInstance(node) => node.wallclock, | ||
CrdsData::DuplicateShred(_, shred) => shred.wallclock, | ||
CrdsData::SnapshotHashes(hash) => hash.wallclock, | ||
CrdsData::ContactInfo(node) => node.wallclock(), | ||
CrdsData::RestartLastVotedForkSlots(slots) => slots.wallclock, | ||
CrdsData::RestartHeaviestFork(fork) => fork.wallclock, | ||
} | ||
} | ||
|
||
pub(crate) fn pubkey(&self) -> Pubkey { | ||
match &self { | ||
CrdsData::LegacyContactInfo(contact_info) => *contact_info.pubkey(), | ||
CrdsData::Vote(_, vote) => vote.from, | ||
CrdsData::LowestSlot(_, slots) => slots.from, | ||
CrdsData::LegacySnapshotHashes(hash) => hash.from, | ||
CrdsData::AccountsHashes(hash) => hash.from, | ||
CrdsData::EpochSlots(_, p) => p.from, | ||
CrdsData::LegacyVersion(version) => version.from, | ||
CrdsData::Version(version) => version.from, | ||
CrdsData::NodeInstance(node) => node.from, | ||
CrdsData::DuplicateShred(_, shred) => shred.from, | ||
CrdsData::SnapshotHashes(hash) => hash.from, | ||
CrdsData::ContactInfo(node) => *node.pubkey(), | ||
CrdsData::RestartLastVotedForkSlots(slots) => slots.from, | ||
CrdsData::RestartHeaviestFork(fork) => fork.from, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated to this exact PR, but why are pubkey
and wallclock
private in ContactInfo
and LegacyContactInfo
but public in the other CrdsData
types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these variants are defined in this same module.
So even if they were private, this code could still access them directly.
if let CrdsData::NodeInstance(value) = value.data() { | ||
if let Some(out) = value.overrides(&other.value) { | ||
return out; | ||
match value.data() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just pass data: &CrdsData
into this function instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we pass CrdsData
, it kind of obfuscates {ContactInfo,NodeInstance}::overrides
api.
Might be more self-explanatory if the api uses a more specific type;
Reorganizing this code in preparation of upcoming changes to CrdsValue (de)serialization.
19b1d9e
to
0999629
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Problem
Reorganizing this code in preparation of upcoming changes to
CrdsValue
(de)serialization.Summary of Changes
split out gossip
CrdsData
out ofcrds_value.rs